-
Notifications
You must be signed in to change notification settings - Fork 20.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
all: live chain-aware tracing #27629
Conversation
Greeting @s1na , I noticed that the StateLogger part of my pull request (#27617) aligns perfectly with what you have already implemented. I'm considering building upon your work. I have a few questions:
|
Hey @joohhnnn. That is an interesting idea to push tracing notifications on a channel to be used with a subscription method. We could have something like Edit: We can totally simplify this at the cost of some flexibility. |
@s1na Thanks for this initial PR, I'm going to start build up upon it to see how it looks like and report once I have played with it a little bit more. |
type noop struct{} | ||
|
||
func newNoopTracer(_ json.RawMessage) (core.BlockchainLogger, error) { | ||
return &noop{}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t := &myTracer{}
return &live.Tracer{
CaptureStart: t.captureStart,
CaptureEnd: r.captureEnd,
}
@@ -141,6 +142,9 @@ type Config struct { | |||
// Enables tracking of SHA3 preimages in the VM | |||
EnablePreimageRecording bool | |||
|
|||
// Enables VM tracing | |||
VMTracer vm.EVMLogger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird. This config object is decoded from the yaml config files. Shouldn't put objects like this here.
|
||
if interpreter.evm.Config.Tracer != nil && returnGas > 0 { | ||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded) | ||
} | ||
|
||
scope.Contract.Gas += returnGas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combine all this into RefundGas
Computer says no |
This PR lets users run a long-running tracer. The tracer will run alongside normal chain processing operations. It will be aware of practically all observable changes to the chain. This allows people to write complete indexing solutions without needing a fork of geth with large footprint over sensitive and often-changing parts of the codebase. E.g. see the discussion at #27003. There are 2 major themes to this:
BlockStart
,BlockEnd
, as well as minute details likeOnNewAccount
,OnBalanceChange
, etc.Given that the native tracers have access to the filesystem, it will be possible for example already to do a full sync and store all call traces in a file. However I plan to work on streamlining this and offering db persistence of traces directly in geth in the future. Then we can offer
trace_filter
-like APIs.Backwards-compatibility
There has been a change in the hooks
CaptureTxStart/CaptureTxEnd
andCaptureStart/End/Enter/Exit
. These hooks have been moved up slightly and will now capture tx/call validation errors. I.e. There will be e.g.CaptureEnter
invocations even if the call fails validation (depth-check or value balance check), and consequentlyCaptureExit
will be called with the error.